<template>
    <div class="bg-fff h-100p bdr-10 pd-10">
        <v-plain-table :native="{stripe:true}" :data="channelCommissioner" @change="change">
            <template slot="expand" slot-scope="{scope}">
                <el-button type="text" @click="$router.push(`/platform/channel-provider/detail/${scope.row.id}`)">
                    详情
                </el-button>
                <el-button type="text" @click="showAudit(scope.row)" v-if="scope.row.userStatus === 0">审核</el-button>
            </template>
        </v-plain-table>
    </div>
</template>

<script lang="ts">
  import { Vue, Component } from 'vue-property-decorator'
  import vPlainTable from '@/components/plain-table'
  import { Getter } from 'vuex-class'

  @Component({
    components: {
      vPlainTable,
    }
  })
  export default class Platform extends Vue {
    channelCommissioner: TableData = {
      header: [
        {
          label: '账号',
          key: 'username'
        },
        {
          label: 'id',
          key: 'id'
        },
        {
          label: '渠道专员名称',
          key: 'realName'
        },
        {
          label: '角色名称',
          key: 'roleName'
        },
        {
          label: '联系方式',
          key: 'contactInformation'
        },
        {
          label: '利润配比',
          key: 'profitRatio'
        },
        {
          label: '平台利润',
          key: 'platformProfit'
        },
        {
          label: '创建日期',
          key: 'createTime',
          formatter: row => this.$utils.toTimeFormat(row.createTime)
        },
        {
          label: '最后登录',
          key: 'date',
          formatter: row => this.$utils.toTimeFormat(row.lastLoginTime)
        }
      ],
      body: [],
      footer: {
        total: 0,
        currentPage: 1
      }
    }
    
    @Getter userInfo
    async getChannelCommissioner () {
      let res: AjaxResponse = await this.$axios.post('b/boms/user/commissioner/list', {
        'currentPage': this.channelCommissioner.footer.currentPage,                //类型：Number  必有字段  备注：无
        'pageSize': 10                //类型：Number  必有字段  备注：无
      })
      this.channelCommissioner.body = res.data.items
      this.channelCommissioner.footer.total = res.data.totalNum
      this.channelCommissioner.footer.currentPage = res.data.currentPage
    }

    change (page) {
      this.channelCommissioner.footer.currentPage = page
      this.getChannelCommissioner()
    }

    mounted () {

      if(this.userInfo.roleType === 1){
        for (let i in this.channelCommissioner.header) {
          if(this.channelCommissioner.header[i].key === 'platformProfit'){
            this.channelCommissioner.header.splice(i ,1)
          }
        }
      }
      this.getChannelCommissioner()
    }
  }
</script>

<style lang="less" scoped>
    .bdr-bottom-10 {
        overflow-y: scroll;
    }
</style>
